import http from '../request';
import {
  CreateCronReqType,
  CreateCronResType,
  CronDeleteReqType,
  CronDeleteResType,
  CronListReqType,
  CronListResType,
  CronInfoReqType,
  CronInfoResType,
  CronUpdateReqType,
  CronUpdateResType,
  ModifyCronReqType,
  ModifyCronResType,
} from '@/types/cron';

// 新增任务
export const createApi = (data: CreateCronReqType): Promise<CreateCronResType> => {
  return http.post('/job/create', data);
};
// 删除任务
export const deleteApi = (data: CronDeleteReqType): Promise<CronDeleteResType> => {
  return http.get('/job/delete', data);
};
// 查询任务列表
export const listApi = (data: CronListReqType): Promise<CronListResType> => {
  return http.post('/job/list', data);
};
// 根据id查询任务列表
export const listByIdApi = (data: CronInfoReqType): Promise<CronInfoResType> => {
  return http.post('/job/info', data);
};
// 修改任务
export const updateApi = (data: CronUpdateReqType): Promise<CronUpdateResType> => {
  return http.post('/job/update', data);
};
// 修改任务执行状态
export const updateStatusApi = (data: ModifyCronReqType): Promise<ModifyCronResType> => {
  return http.post('/job/updateStatus', data);
};
// 重载任务
export const reloadApi = (): Promise<any> => {
  return http.get('/job/reload');
};
